package movee.jpa.multi.source.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 *
 *
 * @author movee
 */
@Getter
@AllArgsConstructor
public enum ChangeType {

    NORMAL_CHANGE(0, "一般变更", ""),
    PREAUTH_CHANGE(1, "预授权变更", ""),
    PLANLESS_CHANGE(2, "临时变更", ""),
    CROSS_TEAM_CHANGE(3, "夸团队变更", ""),
    CUSTOM_CHANGE(3, "外部客户变更", ""),
    DUTY_CHANGE(3, "值班变更", ""),
    UNAUTH_CHANGE(4, "无单变更", "");

    private final int id;
    private final String chineseName;
    private final String description;

    private static final Map<String, ChangeType> CHINESE_MAP = new HashMap<>();
    private static final Map<String, ChangeType> NAME_MAP = new HashMap<>();

    static {
        for (ChangeType type : ChangeType.values()) {
            CHINESE_MAP.put(type.getChineseName().toLowerCase(), type);
            NAME_MAP.put(type.name().toLowerCase(), type);
        }
    }

    public static ChangeType fromChineseName(String chineseName) {
        return chineseName == null ? null : CHINESE_MAP.get(chineseName.toLowerCase());
    }

    public static ChangeType fromName(String name) {
        return name == null ? null : NAME_MAP.get(name.toLowerCase());
    }
}
